/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package we.dispatcher.packet;

import java.util.logging.Level;
import java.util.logging.Logger;
import we.dispatcher.CPacketReader;

/**
 *
 * @author ADMIN
 */
public abstract class CReceivedPacket
{

    protected boolean valid;
    protected CPacketReader reader;
    protected int id;

    public CReceivedPacket(CPacketReader reader)
    {
        this(0, reader);
    }

    public CReceivedPacket(int id, CPacketReader reader)
    {
        this.reader = reader;
        this.id = id;
        valid = true;
        try
        {
            processData();
        } catch (Exception ex)
        {
            valid = false;
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Loi khoi tao Packet", ex);
        }
    }

    public int getID()
    {
        return id;
    }

    public boolean isValid()
    {
        return valid;
    }

    abstract protected void processData() throws Exception;
}
